#pragma once
#include <d3dx9.h>
#include <map>
#include <string>

using std::string;
using std::map;

#include "String.h"
#include "Common.h"
#include "../frame/frame.h"

class Texture;

class TextureMgr
{
public:
								~TextureMgr();
	static TextureMgr*			Instance();

	void						InitTextureState();
	Texture*					GetTexture( string key );

	Texture*					CreateTexture( String filename, string key );
	Texture*					CreateTextureEX( String filename, string key );
	void						ReleaseTextures();
private:
								TextureMgr(){}
								TextureMgr( const TextureMgr& mgr );
	TextureMgr&					operator=( const TextureMgr& mgr );


	static TextureMgr*			mTexMgr;
	map< string, Texture* >		mTexs;
};

class Texture
{
public:
								Texture() { mTex = NULL; }
								~Texture() { Release(); }

	void						Release() { SAFE_RELEASE( mTex ); }

	void						SetTexture( LPDIRECT3DTEXTURE9 tex ) { mTex = tex; }
	void						SetWidth( UINT width ) { mWidth = width; }
	void						SetHeight( UINT height ) { mHeight = height; }

	LPDIRECT3DTEXTURE9			GetTexture() { return mTex; }
	UINT						GetWidth() { return mWidth; }
	UINT						GetHeight() { return mHeight; }
private:
	LPDIRECT3DTEXTURE9			mTex;
	UINT						mWidth;
	UINT						mHeight;
};